<?php //IPCLOACK
if (DEBUG == false) {
	error_reporting(0);
}
if (CLOAKING_LEVEL !== 4) {
	$timestamp = filemtime(FILE_BOTS);
	$lastupdated = date("Ymd",$timestamp);
	if ($lastupdated != date("Ymd")) {
		$lists = array(
		'http://spiders.wphost.info/google.txt',
		'http://spiders.wphost.info/inktomi.txt',
		'http://spiders.wphost.info/lycos.txt',
		'http://spiders.wphost.info/msn.txt',
		'http://spiders.wphost.info/altavista.txt',
		'http://spiders.wphost.info/askjeeves.txt',
		'http://spiders.wphost.info/wisenut.txt',
		);
		foreach($lists as $list) {
			$opt .= fetch($list);
		}
		$opt = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $opt);
		$fp =  fopen(FILE_BOTS,"w");
		fwrite($fp,$opt);
		fclose($fp);
	}
	$ip = $_SERVER["REMOTE_ADDR"];
	$ref = $_SERVER['HTTP_REFERER'];
	$agent = $_SERVER['HTTP_USER_AGENT'];
	$host = strtolower(gethostbyaddr($ip));
	$file = implode(" ", file(FILE_BOTS));
	$exp = explode(".", $ip);
	$class = $exp[0].'.'.$exp[1].'.'.$exp[2].'.';
	$threshold = CLOAKING_LEVEL;
	if (stristr($host, "googlebot") && stristr($host, "inktomi") && stristr($host, "msn")) {
		$cloak++;
	}
	if (stristr($file, $class)) {
		$cloak++;
	}
	if (stristr($file, $agent)) {
		$cloak++;
	}
	if (strlen($ref) > 0) {
		$cloak = 0;
	}
	// PERFORM CLOAK DATA ANALYSIS
	if ($cloak >= $threshold) {
		$cloakdirective = 1;
	} 
	else {
		$cloakdirective = 0;
	}
}
?>